#!/usr/bin/env python
# coding=utf-8
# 框架拖动页

import wsgiref.handlers
from google.appengine.ext import webapp
from google.appengine.api import users
from google.appengine.ext.webapp import util
import common

class DragHandler(webapp.RequestHandler):
	def get(self):
		self.response.headers["Content-Type"] = "text/html; charset=utf-8"
		self.response.out.write("""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Drag - Beikx Cron</title>
    <link href="css/style.css" type="text/css" rel="stylesheet" />
    <style type="text/css">
    body {
      margin: 0;
      padding: 0;
      background: #80BDCB;
      cursor: E-resize;
    }
    </style>
    <script type="text/javascript" language="javascript">
<!--
var pic = new Image();
pic.src="images/arrow_right.gif";
function toggleMenu()
{
  frmBody = parent.document.getElementById('frame-body');
  imgArrow = document.getElementById('img');
  if (frmBody.cols == "0, 10, *")
  {
    frmBody.cols="200, 10, *";
    imgArrow.src = "images/arrow_left.gif";
  }
  else
  {
    frmBody.cols="0, 10, *";
    imgArrow.src = "images/arrow_right.gif";
  }
}
var orgX = 0;
document.onmousedown = function(e)
{
  var evt = Utils.fixEvent(e);
  orgX = evt.clientX;
  if (Browser.isIE) document.getElementById('tbl').setCapture();
}
document.onmouseup = function(e)
{
  var evt = Utils.fixEvent(e);
  frmBody = parent.document.getElementById('frame-body');
  frmWidth = frmBody.cols.substr(0, frmBody.cols.indexOf(','));
  frmWidth = (parseInt(frmWidth) + (evt.clientX - orgX));
  frmBody.cols = frmWidth + ", 10, *";
  if (Browser.isIE) document.releaseCapture();
}
var Browser = new Object();
Browser.isMozilla = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined') && (typeof HTMLDocument != 'undefined');
Browser.isIE = window.ActiveXObject ? true : false;
Browser.isFirefox = (navigator.userAgent.toLowerCase().indexOf("firefox") != - 1);
Browser.isSafari = (navigator.userAgent.toLowerCase().indexOf("safari") != - 1);
Browser.isOpera = (navigator.userAgent.toLowerCase().indexOf("opera") != - 1);
var Utils = new Object();
Utils.fixEvent = function(e)
{
  var evt = (typeof e == "undefined") ? window.event : e;
  return evt;
}
//-->
</script>
</head>
<body>
    <table cellspacing="0" cellpadding="0" id="tbl" style="height:100%;">
        <tr>
            <td style="vertical-align:middle;height:100%;">
                <a href="javascript:toggleMenu();"><img src="images/arrow_left.gif" width="10" height="30" alt="" id="img" style="border:none 0px white;" /></a></td>
        </tr>
    </table>
<script type="text/javascript" language="javascript">
<!--
    var e = window.innerHeight;
    if(e == null)
	    e = document.documentElement.offsetHeight;
	document.getElementById('tbl').style.height = '' + e + 'px';
// -->
</script>
</body>
</html>""")

def main():
	application = webapp.WSGIApplication([('/drag', DragHandler)],
		debug=True)
	util.run_wsgi_app(application)


if __name__ == '__main__':
	main()
